﻿--#include "data\config\activityconfig\DailyActivity\TwelvePalacesConfig.lua" once   --十二星宫
--#include "data\functions\Activity\DailyActivity\TwelvePalaces.lua" once  


local npcId = 102
NpcDialog[npcId] = {}
local t = NpcDialog[npcId]

t.main = function(sysarg)
	local levelLimit = TwelvePalacesCfg.floors[1].enterLevelLimit[2]
	local strColor1 = Lang.ScriptTips.Color_Greed
	if not Actor.checkActorLevel( sysarg, TwelvePalacesCfg.floors[1].enterLevelLimit[2], TwelvePalacesCfg.floors[1].enterLevelLimit[1] ) then
		strColor1 = Lang.ScriptTips.Color_Red
	end

	local strCond1 = string.format( Lang.ScriptTips.LevelLimitFormat, strColor1, levelLimit )
	local strCond  = strCond1
	-----------------
	local strDesc 		= ""
	local okBtn 		= ""			--{按钮;样式;按钮名;函数名;描述}
	local strBtnList 	= ""
	local sceneId 		= Actor.getSceneId( sysarg )
	local floorSts 		= TwelvePalacesGetFloorSts( sceneId )
	if floorSts == 0 then
		strDesc 	=  Lang.ScriptTips.Twelvelpalaces01
		okBtn 		= "{btn;0;"..Lang.ScriptTips.ButtonEnter..";%s;}"			--{按钮;样式;按钮名;函数名;描述}
		strBtnList 	= string.format(okBtn, "EnterTwelvePalacesFromNpc")
	elseif floorSts == 1 then
		local floorCfg 	= GetTwelePalacesFloorCfgBySceneId( Actor.getSceneId(sysarg) )		--当前楼层
		if not floorCfg then
			return
		end

		strDesc 	= Lang.ScriptTips.Twelvelpalaces02
		local button1 	= string.format( Lang.ScriptTips.ButtonEnterNext)
		local okBtn1 	= "{btn;0;"..button1..";%s;}"		--{按钮;样式;按钮名;函数名;描述}
		local strBtn1 	= string.format(okBtn1, "NextTwelvePalacesFromNpcByItem")
		strBtnList	= strBtn1

		--[[local checkItemId		= floorCfg.checkItem[1]
		local checkItemCount	= floorCfg.checkItem[2]
		local itemName			= Item.getItemName( checkItemId )
		local needCount	= floorCfg.checkItem[2]
		local button1 	= string.format( Lang.ScriptTips.ButtonItemNext, itemName, needCount )
		local okBtn1 	= "{btn;0;"..button1..";%s;}"		--{按钮;样式;按钮名;函数名;描述}
		local strBtn1 	= string.format(okBtn1, "NextTwelvePalacesFromNpcByItem")
		strBtnList	= strBtn1

		if floorCfg.nextFloor[2] then		--需要元宝，才显示元宝按钮
			local needYuanBao =  floorCfg.nextFloor[2].consume[1].count		
			local button2 	= string.format( Lang.ScriptTips.ButtonBYBNext, needYuanBao )
			local okBtn2 	= "{btn;0;"..button2..";%s;}"
			local strBtn2 	= string.format(okBtn2, "NextTwelvePalacesFromNpcByYuanBao")
			strBtnList	= strBtnList..strBtn2
		end
		
		strBtnList	= strBtnList..strBtn2]]
	elseif floorSts == 2 then
		strDesc 	= Lang.ScriptTips.Twelvelpalaces03
		okBtn 		= "{btn;0;"..Lang.ScriptTips.ButtonExit..";%s;}"			--{按钮;样式;按钮名;函数名;描述}
		strBtnList 	= string.format(okBtn, "QuitTwelvePalacesFromNpc")
	end
	------------------
	

	--local localFun = string.format("OpenView,%s,%d", enLinkBuyItemWnd, cfg.itemId)
	--strBtnList = strBtnList .. string.format(cfg.buyBtn, localFun)

	-----------------
	local pack = DataPack.allocPacket(sysarg, LogicCmd.npcDialogSys.sysID, LogicCmd.npcDialogSys.sub.sNpcDlgData)
	
	DataPack.writeUint64(pack, Actor.getNpc(sysarg))
	DataPack.writeByte(pack, NpcDialogType.FYSDNpcDlg)
	DataPack.writeString(pack, strCond)
	DataPack.writeString(pack, strDesc)
	DataPack.writeString(pack, strBtnList)
	DataPack.writeChar(pack, -1)
	DataPack.writeByte(pack, 0);
	DataPack.flush(pack)

	return str
end

--进入十二星宫
t.EnterTwelvePalacesFromNpc = function ( sysarg )
	--print("EnterTwelvePalacesFromNpc...")
	Actor.closeNPCDialog(sysarg)
	EnterTwelvePalacesFloor( sysarg )
end

--道具进入下一层
t.NextTwelvePalacesFromNpcByItem = function ( sysarg )
	--print("NextTwelvePalacesFromNpc...")
	Actor.closeNPCDialog(sysarg)
	EnterTwelePalacesNextFloor( sysarg, 1 )				--1-道具进入，2-元宝进入
end

--元宝进入下一层
t.NextTwelvePalacesFromNpcByYuanBao = function ( sysarg )
	--print("NextTwelvePalacesFromNpc...")
	Actor.closeNPCDialog(sysarg)
	EnterTwelePalacesNextFloor( sysarg, 2 )				--1-道具进入，2-元宝进入
end

--退出BOSS之家
t.QuitTwelvePalacesFromNpc = function ( sysarg )
	--print("QuitTwelvePalacesFromNpc...")
	Actor.closeNPCDialog(sysarg)
	TwelvePalacesQuit( sysarg )
end